from django.db import models
from meiduo_mall.utils.models import BaseModel
from users.models import User

# Create your models here.
class Area(models.Model):
    name = models.CharField(max_length=20,verbose_name='名称')
    parent = models.ForeignKey('self',related_name='subs',on_delete=models.SET_NULL,null=True,blank=True,verbose_name='上级行政区')
    # related_name 相当于修改BookInfo中的隐藏字段heroinfo_set的值，在HefoInfo中的外键设置
    # on_delete 删除时候，外键对应的值改为null,前提是blank=True
    class Meta:
        db_table = 'tb_areas'
        verbose_name = '省市区'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.name

